<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>校园宿舍管理系统 - 修改密码</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            background: linear-gradient(to right, #e0f7fa, #ffffff);
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        .password-container {
            max-width: 600px;
            margin: 80px auto;
            padding: 30px;
            background: #ffffff;
            border-radius: 12px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
            animation: fadeIn 1s ease-in-out;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .form-label {
            font-weight: 600;
            color: #333;
        }
        .form-control:focus {
            border-color: #17a589;
            box-shadow: 0 0 0 0.2rem rgba(23, 165, 137, 0.25);
        }
        .btn-primary {
            background-color: #17a589;
            border-color: #17a589;
            transition: background-color 0.3s ease;
        }
        .btn-primary:hover {
            background-color: #148f77;
            border-color: #148f77;
        }
        .alert {
            border-radius: 8px;
        }
        .password-tips {
            margin-top: 15px;
            padding: 10px;
            background-color: #f1f9f4;
            border-left: 4px solid #17a589;
            color: #333;
            font-size: 0.95rem;
        }
        .footer-link {
            margin-top: 20px;
            display: block;
            color: #17a589;
            text-decoration: none;
            font-weight: 500;
        }
        .footer-link:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark" style="background-color: #17a589;">
    <div class="container">
        <a class="navbar-brand" href="#">校园宿舍管理系统</a>
        <div class="collapse navbar-collapse">
            <ul class="navbar-nav me-auto">
                <li class="nav-item">
                    <a class="nav-link" th:href="@{/home}">首页</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" th:href="@{/student/list}">学生管理</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" th:href="@{/dormitory/list}">宿舍管理</a>
                </li>
            </ul>
            <div class="d-flex">
                <span class="navbar-text me-3" th:text="'欢迎，' + ${session.user.username}"></span>
                <a class="btn btn-outline-light" th:href="@{/user/logout}">退出</a>
            </div>
        </div>
    </div>
</nav>
<div class="container">
    <div class="password-container">
        <h2 class="text-center mb-4">修改密码</h2>
        <div th:if="${message}" class="alert alert-warning" role="alert" th:text="${message}"></div>
        <form th:action="@{/user/changePassword}" method="post">
            <div class="mb-3">
                <label for="oldPassword" class="form-label">旧密码</label>
                <input type="password" class="form-control" id="oldPassword" name="oldPassword" required
                       placeholder="请输入当前密码">
            </div>
            <div class="mb-3">
                <label for="newPassword" class="form-label">新密码</label>
                <input type="password" class="form-control" id="newPassword" name="newPassword" required
                       placeholder="请输入新密码">
                <div class="form-text">密码必须包含字母和数字，至少8位</div>
            </div>
            <div class="password-tips">
                <strong>建议：</strong>请设置一个容易记住但不易被他人猜测的密码，以保障账户安全。
            </div>
            <button type="submit" class="btn btn-primary w-100 mt-3">确认修改</button>
        </form>
        <a th:href="@{/home}" class="footer-link d-block text-center mt-4">返回首页</a>
    </div>
</div>
</body>
</html>